package com.jac.alapores.rest;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.jac.alapores.domain.Alapores;
import com.jac.alapores.domain.AlaporesHero;
import com.jac.alapores.domain.AvailableRecruits;
import com.jac.alapores.domain.Territory;
import com.jac.alapores.manager.AlaporesManager;

@Path("/rest/recruit")
public class RecruitController
{
	private static final AlaporesManager ALAPORES_MANAGER = new AlaporesManager();	

	@GET
	@Produces({MediaType.APPLICATION_JSON})
	@Path("/list/{venueID}")
	public AvailableRecruits list(@PathParam("venueID") String venueID)
	{
		return ALAPORES_MANAGER.fetchAvailableRecruits(venueID);
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/addRecruit")
	public String addRecruitedAlapores(AddAlaporesObject addAlaporesObject)
	{
		ALAPORES_MANAGER.addRecruit(addAlaporesObject.alaporesIDs, addAlaporesObject.userID);
		return "success";
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/addHeroAlapores")
	public String addHeroAlapores(AlaporesHero alaporesHero)
	{
		ALAPORES_MANAGER.addAlaporesHero(alaporesHero);
		return "success";
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/addAlapores")
	public String addAlapores(Alapores alapores)
	{
		ALAPORES_MANAGER.addAlapores(alapores);
		return "success";
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/addTerritory")
	public String addTeritory(Territory territory)
	{
		ALAPORES_MANAGER.addTerritory(territory);
		return "success";
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/addUser")
	public String addUser(Territory territory)
	{
		ALAPORES_MANAGER.addTerritory(territory);
		return "success";
	}	
	
	
	//should handle this better
	private class AddAlaporesObject
	{
		public List<Long> alaporesIDs;
		public String userID;
	}
}
